using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerDashState : PlayerState
{
    public PlayerDashState(Player player, StateMachine<PlayerState> stateMachine, string animBoolName) : base(player, stateMachine, animBoolName)
    {
    }

    public override void Enter()
    {
        base.Enter();
        stateTimer.Timer = player.dashDuration;
        player.skill.dashSkill.CreateCloneInDashStart();
       
    }

    public override void Exit()
    {
        base.Exit();
        player.SetVelocity(0f, rb.velocity.y);
        player.skill.dashSkill.CreateCloneInDashEnd();
    }

    public override void Update()
    {
        base.Update();
        player.SetVelocity(player.DashDir * player.dashSpeed,0); 
        if (stateTimer.isOver())
        {
            stateMachine.ChangeState(player.idleState);
        }

        if (!player.IsGroundDetected() && player.IsWallDetected())
        {
            player.dashCounterInAir = 0;
            stateMachine.ChangeState(player.wallSlideState);
        }
    }
}
